package 笔试;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class 蚂蚁_小红的数字串 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        int k = scan.nextInt();
        String kk = k + "";
        int count = 0;
        char[] arr = s.toCharArray();
        if(kk.length() > arr.length) {
            System.out.println(count);
            System.exit(0);
        }
        int tmp = kk.length();
        int tmp2 = arr.length;
        while(tmp-- > 1) {
            count += tmp2;
            tmp2--;
        }

        for (int i = 0; i < s.length()-kk.length(); i++) {
            StringBuilder sb = new StringBuilder();

            for (int j = i; j < i+kk.length(); j++) {
                sb.append(s.charAt(j));
            }
            int I = Integer.parseInt(sb.toString());
            if(I < k) {
                count++;
            }
        }
        System.out.println(count);

    }
}
